package net.wanho.controller;

import lombok.RequiredArgsConstructor;
import net.wanho.R.R;
import net.wanho.service.IndexService;
import net.wanho.vo.InventVo;
import net.wanho.vo.PageInfo;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 这个类是：
 *
 * @author: MENG HU WANG
 * @date: 2025/2/7 15:49
 * @version: 1.0
 */

@RestController
@RequiredArgsConstructor
@RequestMapping("/index")
public class IndexController {

    private final IndexService indexService;

    // 库存预警
    @GetMapping("inventWarning")
    public R inventWarning(@RequestParam(defaultValue = "1") Integer pageNum,
                           @RequestParam(defaultValue = "5") Integer pageSize) {
        PageInfo<InventVo> pageInfo = indexService.inventWarning(pageNum, pageSize);
        return R.ok(pageInfo);
    }

    // 临期预警
    @GetMapping("overdueWarning")
    public R overdueWarning(@RequestParam(defaultValue = "1") Integer pageNum,
                            @RequestParam(defaultValue = "5") Integer pageSize) {
        PageInfo<InventVo> pageInfo = indexService.overdueWarning(pageNum, pageSize);
        return R.ok(pageInfo);
    }
}
